﻿// <copyright file="admin_News_Create.aspx.cs" company="NTalent">
// Copyright (c) 2010, NTalent, Inc. All rights reserved
// </copyright>
// <author>卢俊坤</author>
// <author>王彦博 符茂松</author>

using System;
using Net.Ntalent.Action50.Core.Controls;
using Net.Ntalent.Action50.Core.Service;
using Net.Ntalent.Action50.Core.Util;

/// <summary>
/// 管理页面，为某个action新建news
/// </summary>
///<author>王彦博</author> 
/// <copyright>
/// Copyright (c) 2010, NTalent, Co. Ltd. All rights reserved.
/// </copyright>
/// <version>1.0.0</version>
public partial class admin_News_Create : PageBase
{
    public admin_News_Create()
    {
        //设置权限，使未登录用户不能访问该页
        authentication = Constants.AUTHENTICATION_ADMIN;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    /// <summary>
    /// 进行新建操作
    /// </summary>
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        try
        {
            string title = HTMLFilter.Strip(TextBox_Title.Text.Trim());
            string content = Helper.FiltScriptAndStyle(FCKeditor1.Value);

            string userIp = Request.UserHostAddress;
            long actionId = Convert.ToInt64(Request.QueryString["actionId"]);
            EditService es = new EditService();
            es.CreateNews(title, content, userIp, actionId);

            //弹出提示新建成功
            Message.Text = "Create News Successfully";
            popupCmd.Text =
                "<script type='text/javascript'>$('.popup').css('display', 'block');$('#alpha').css('display', 'block')</script>";
        }
        catch (Exception exc)
        {
            //弹出提示新建失败
            Message.Text = "Create News Failed";
            popupCmd.Text =
                "<script type='text/javascript'>$('.popup').css('display', 'block');$('#alpha').css('display', 'block');</script>";
        }
    }

    /// <summary>
    /// Logout
    /// </summary>
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        AuthenticationService authenticationService = new AuthenticationService();
        authenticationService.LogOut();
        Response.Redirect(Request.UrlReferrer.ToString());
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        popupCmd.Text = string.Empty;
        string newPage = "admin_News_View.aspx?actionId=" + Request["actionId"];
        Server.Transfer(newPage);
    }
}
